import java.util.ArrayList;
import java.util.List;

/**
 * 对象结构类
 * @author liaosh
 * @date 2022-10-22 22:10
 */
public class ObjectStructure {
    private List<Person> elements = new ArrayList<>();

    public void attach(Person person) {
        elements.add(person);
    }

    public void detach(Person person) {
        elements.remove(person);
    }

    public void display(Action visitor) {
        for (Person element : elements) {
            element.accept(visitor);
        }
    }
}
